/*
 * @Descripttion:共用接口配置文件
 * @Author: caijj
 * @Date: 2020-11-24 16:59:47
 * @LastEditors: caijj
 * @LastEditTime: 2021-03-03 15:19:25
 */

import request from '@/utils/request';
/**
 * 字典查询
 * */
export const getDictList = data =>
  request({
    url: '/api/dict/getList',
    method: 'POST',
    data: data
  });
/**
 * 字典查询2
 * */
export const getDictListV2 = data =>
  request({
    url: '/api/dict/getListV2',
    method: 'POST',
    data: data
  });
/**
 * 字典查询标题公式详细
 * */
export const getTitleDetl = data =>
  request({
    url: '/api/dict/get',
    method: 'POST',
    data: data
  });

/**
 * 查询商品类型
 * */
export const getCommodityReportList = data =>
  request({
    url: '/api/commodity/types',
    method: 'GET'
  });

/**
 * @Descripttion: 商品业绩接口
 * @param {
    businessCategory: 0,
    cities: [],
    dateBegin: ,
    dateEnd: ,
    dateType: 0,
    goodsCategories: [],
    queryMode: ,
    regions: [],
    stores: []
  } data
 * @return {*}
 */
export const getPerformanceReport = data =>
  request({
    url: '/api/performance/report/getReport',
    method: 'post',
    data: data
  });

// 自有品牌
export const getBrandReport = data =>
  request({
    url: '/api/brand/report/getReport',
    method: 'post',
    data: data
  });

/**
 * @Descripttion:  获取商品类别级联接口
 * @param {
    goodsCategoriesFour: [],
    goodsCategoriesOne: [],
    goodsCategoriesThree: [],
    goodsCategoriesTwo: [],
    level: One
 * } data
 * @return {*}
 */
export const getCommodityDictList = data =>
  request({
    url: '/api/commodity/typesByLevel',
    method: 'post',
    data: data
  });
/**
  * @Descripttion:共用生成报表接口
  * @param {
  *   type: 'performance'| 'brand' | 'stock'
  *   data: {}
  * }
  * @return {*}
  */
export const exportReport = (type, data) => {
  return request({
    url: `/api/${type}/report/exportReport`,
    method: 'post',
    data: data
  });
};
  /**
 * @Descripttion:  共用获取报表下载接口
 * @param {
 *  type: 'performance'| 'brand' | 'stock',
 *  data: {}
 * }
 * @return {*}
 */
export const getReportDownloadUrl = (type, data) =>
  request({
    url: `/api/${type}/report/getReportDownloadUrl`,
    method: 'post',
    data: data
  });

/**
 * @Descripttion:  获取部门树
 */
export const getDepartmentTree = data =>
  request({
    url: '/api/department/getTree',
    method: 'post',
    params: data
  });

/* 获取商业报表数据 */
export const getCommodityPerformanceReport = data =>
  request({
    url: '/api/performance/report/commodity/getReport',
    method: 'post',
    data: data
  });
